package com.hgw.Demo01_ChainOfResponsibilityPattern.examples;

/**
 * Data time:2021/12/16 12:45
 * StudentID:2019112118
 * Author:hgw
 * Description: 董事长类，充当具体处理者
 */
public class President extends Approver {
    public President(String name) {
        super(name);
    }

    // 具体请求处理方法
    @Override
    public void processRequest(PurchaseRequest request) {
        if (request.getAmount() < 500000) {       // 处理请求
            System.out.println("董事长：" + this.name + "审批采购单：" + request.getNumber() +
                    "，金额：" + request.getAmount() + "元，采购目的：" + request.getPurpose() + ".");
        } else {
            this.successor.processRequest(request); // 转发请求
        }
    }
}
